package com.nsgf.library.data.bean;

import android.view.View;

import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import com.nsgf.library.BR;
import com.nsgf.library.data.api.APIs;
import com.nsgf.skjz.utils.Kits;
import com.nsgf.skjz.utils.StringUtil;

import java.io.Serializable;
import java.util.Calendar;
import java.util.List;

public class ClockInBean {

    /**
     * code : 200
     * msg : success
     * data : {"clockInTime":"08:40:46","clockInLabel":null,"clockOutTime":"15:49:14","clockOutLabel":null,"workStartTime":"08:00:00","workEndTime":"17:00:00","distance":500,"lon":"118.87647699933427","lat":"32.01348037678468","attendanceTime":"周一、二、三、四、五 08:00-17:00"}
     */

    private int code;
    private String msg;
    private DataBean data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class Point {
        private double lat;
        private double lon;

        public Point() {
        }

        public Point(double lat, double lon) {
            this.lat = lat;
            this.lon = lon;
        }

        public double getLat() {
            return lat;
        }

        public void setLat(double lat) {
            this.lat = lat;
        }

        public double getLon() {
            return lon;
        }

        public void setLon(double lon) {
            this.lon = lon;
        }
    }

    public static class DataBean extends BaseObservable {

        private String clockInTime;
        private String clockInLabel;
        private String clockOutTime;
        private String clockOutLabel;
        private String workStartTime;
        private String workEndTime;
        private int distance;
        private double lon;
        private double lat;
        private String attendanceTime;
        private String title;

        private String check;

        public String getCheck() {
            return check;
        }

        public void setCheck(String check) {
            this.check = check;
        }

        private String distanceClock;

        private int attendanceCount;
        private List<LateAndEarlyListBean> lateAndEarlyList;
        private List<LateAndEarlyListBean> absentList;
        private List<LateAndEarlyListBean> unClockList;
        private List<LateAndEarlyListBean> attendanceList;


        private List<LateAndEarlyListBean> list;

        private String facilityName;
        private String facilityTypeDesc;

        //@Schema(description = "我的待办数量")
        private String toDoNum;

        //@Schema(description = "告警信息数量")
        private String warning;

        //@Schema(description = "消息推送数量")
        private String msgPushNum;

        //@Schema(description = "通知公告")
        private String notice;

        //@Schema(description = "当前水位")
        private String currentH;

        //@Schema(description = "当前库容")
        private String currentKr;

        //@Schema(description = "一小时雨量")
        private String rainfall;

        //@Schema(description = "24小时雨量")
        private String rainfall24;

        private String area;

        private List<WorkOrderDetailBean.FileDto> files;

        private boolean checked;
        private List<LibraryInfo> workSituation;
        //当前水位更新时间
        private String currentHTm;
        //当前库容更新时间
        private String currentKrTm;
        //雨量更新时间
        private String rainfallTm;

        private String label;

        private Point[] points;

        public void setPoints(Point[] points) {
            this.points = points;
        }

        public Point[] getPoints() {
            return points;
        }

        public DataBean() {

        }

        public DataBean(String title, List<LateAndEarlyListBean> list) {
            this.title = title;
            this.list = list;
        }

        public String getClockInTime() {
            return StringUtil.isEmpty(clockInTime) ? "未打卡" : clockInTime;
        }

        public void setClockInTime(String clockInTime) {
            this.clockInTime = clockInTime;
        }

        public String getClockInLabel() {
            return clockInLabel;
        }

        public int getClockInLabelVisible() {
            return StringUtil.isEmpty(clockInLabel) ? View.GONE : View.VISIBLE;
        }

        public void setClockInLabel(String clockInLabel) {
            this.clockInLabel = clockInLabel;
        }

        public String getClockOutTime() {
            return StringUtil.isEmpty(clockOutTime) ? "未打卡" : clockOutTime;
        }

        public void setClockOutTime(String clockOutTime) {
            this.clockOutTime = clockOutTime;
        }

        public String getClockOutLabel() {
            return clockOutLabel;
        }

        public int getClockOutLabelVisible() {
            return StringUtil.isEmpty(clockOutLabel) ? View.GONE : View.VISIBLE;
        }

        public void setClockOutLabel(String clockOutLabel) {
            this.clockOutLabel = clockOutLabel;
        }

        public String getWorkStartTime() {
            return workStartTime;
        }

        public void setWorkStartTime(String workStartTime) {
            this.workStartTime = workStartTime;
        }

        public String getWorkEndTime() {
            return workEndTime;
        }

        public void setWorkEndTime(String workEndTime) {
            this.workEndTime = workEndTime;
        }

        public int getDistance() {
            return distance;
        }

        public void setDistance(int distance) {
            this.distance = distance;
        }

        public String getDistanceSrc() {
            return "1. 考勤地点:水库" + distance + "m范围内\n2. 考勤时间:" + attendanceTime;
        }

        public double getLon() {
            return lon;
        }

        public void setLon(double lon) {
            this.lon = lon;
        }

        public double getLat() {
            return lat;
        }

        public void setLat(double lat) {
            this.lat = lat;
        }

        public String getAttendanceTime() {
            return attendanceTime;
        }

        public void setAttendanceTime(String attendanceTime) {
            this.attendanceTime = attendanceTime;
        }


        @Bindable
        public String getDistanceClock() {
            return distanceClock;
        }

        public void setDistanceClock(double distanceClock) {
            if (distanceClock > distance) {
                this.distanceClock = "您未进入" + UserInfo.getInstance().getProjectName();
            } else
                this.distanceClock = "您已进入" + UserInfo.getInstance().getProjectName();
            notifyPropertyChanged(BR.distanceClock);
        }

        public void setDistanceClock(boolean distanceClock) {
            if (!distanceClock) {
                this.distanceClock = "您未进入" + UserInfo.getInstance().getProjectName();
            } else
                this.distanceClock = "您已进入" + UserInfo.getInstance().getProjectName();
            notifyPropertyChanged(BR.distanceClock);
        }

        public int getAttendanceCount() {
            return attendanceCount;
        }

        public void setAttendanceCount(int attendanceCount) {
            this.attendanceCount = attendanceCount;
        }

        public List<LateAndEarlyListBean> getLateAndEarlyList() {
            return lateAndEarlyList;
        }

        public void setLateAndEarlyList(List<LateAndEarlyListBean> lateAndEarlyList) {
            this.lateAndEarlyList = lateAndEarlyList;
        }

        public List<LateAndEarlyListBean> getAbsentList() {
            return absentList;
        }

        public void setAbsentList(List<LateAndEarlyListBean> absentList) {
            this.absentList = absentList;
        }

        public String getTitle() {
            return StringUtil.isEmpty(title) ? getFacilityTypeDesc() : title;
        }

        public void setTitle(String title) {
            this.title = title;
        }

        public List<LateAndEarlyListBean> getList() {
            return list;
        }

        public void setList(List<LateAndEarlyListBean> list) {
            this.list = list;
        }

        public String getFacilityName() {
            return facilityName;
        }

        public void setFacilityName(String facilityName) {
            this.facilityName = facilityName;
        }

        public String getToDoNum() {
            return toDoNum;
        }

        public void setToDoNum(String toDoNum) {
            this.toDoNum = toDoNum;
        }

        public String getWarningNum() {
            return warning;
        }

        public void setWarningNum(String warning) {
            this.warning = warning;
        }

        public String getMsgPushNum() {
            return msgPushNum;
        }

        public void setMsgPushNum(String msgPushNum) {
            this.msgPushNum = msgPushNum;
        }

        public String getNotice() {
            return notice;
        }

        public void setNotice(String notice) {
            this.notice = notice;
        }

        public String getCurrentH() {
            if (Kits.Date.isToday(Kits.Date.timeStrToSecond(currentHTm)))
                return StringUtil.isEmpty(currentH) ? "--" : currentH;
            else return "--";
        }

        public void setCurrentH(String currentH) {
            this.currentH = currentH;
        }

        public String getCurrentKr() {
            if (Kits.Date.isToday(Kits.Date.timeStrToSecond(currentHTm)))
                return StringUtil.isEmpty(currentKr) ? "--" : currentKr;
            else return "--";
        }

        public void setCurrentKr(String currentKr) {
            this.currentKr = currentKr;
        }

        public String getRainfall() {
            return StringUtil.isEmpty(rainfall) ? "--" : rainfall;
        }

        public void setRainfall(String rainfall) {
            this.rainfall = rainfall;
        }

        public String getRainfall24() {
            return rainfall24;
        }

        public void setRainfall24(String rainfall24) {
            this.rainfall24 = rainfall24;
        }

        public List<WorkOrderDetailBean.FileDto> getFiles() {
            return files;
        }

        public void setFiles(List<WorkOrderDetailBean.FileDto> files) {
            this.files = files;
        }

        @Bindable
        public boolean isChecked() {
            return checked;
        }

        public void setChecked(boolean checked) {
            this.checked = checked;
            notifyPropertyChanged(BR.checked);
        }

        public String getArea() {
            return area;
        }

        public void setArea(String area) {
            this.area = area;
        }

        public String getFacilityTypeDesc() {
            return StringUtil.isEmpty(facilityTypeDesc) ? "" : facilityTypeDesc;
        }

        public void setFacilityTypeDesc(String facilityTypeDesc) {
            this.facilityTypeDesc = facilityTypeDesc;
        }

        public List<LibraryInfo> getWorkSituation() {
            return workSituation;
        }

        public void setWorkSituation(List<LibraryInfo> workSituation) {
            this.workSituation = workSituation;
        }

        public String getCurrentHTm() {
            if (Kits.Date.isToday(Kits.Date.timeStrToSecond(currentHTm)))
                return StringUtil.isEmpty(currentHTm) ? "--" : Kits.Date.getMdHm(Kits.Date.timeStrToSecond(currentHTm));
            else return "--";
        }

        public void setCurrentHTm(String currentHTm) {
            this.currentHTm = currentHTm;
        }

        public String getCurrentKrTm() {
            return StringUtil.isEmpty(currentKrTm) ? "--" : currentKrTm;
        }

        public void setCurrentKrTm(String currentKrTm) {
            this.currentKrTm = currentKrTm;
        }

        public String getRainfallTm() {
            return (StringUtil.isEmpty(rainfallTm) || StringUtil.isEmpty(rainfall)) ? "--" : rainfallTm;
        }

        public void setRainfallTm(String rainfallTm) {
            this.rainfallTm = rainfallTm;
        }

        public String getLabel() {
            return label;
        }

        public void setLabel(String label) {
            this.label = label;
        }

        public List<LateAndEarlyListBean> getUnClockList() {
            return unClockList;
        }

        public void setUnClockList(List<LateAndEarlyListBean> unClockList) {
            this.unClockList = unClockList;
        }

        public List<LateAndEarlyListBean> getAttendanceList() {
            return attendanceList;
        }

        public void setAttendanceList(List<LateAndEarlyListBean> attendanceList) {
            this.attendanceList = attendanceList;
        }

        public static class LateAndEarlyListBean implements Serializable {

            private String id;
            private String clockDate;
            private int dayOfWeek;
            private String content;
            private String facilityType;
            private String facilityName;
            private String deviceCode;
            private String deviceName;
            private String coordinates;
            private String callingMode;
            private Object list;
            private String lat;
            private String lon;
            private String location;
            private String pictureUrl;
            private String projectCode;
            private String clockInTime;
            private String clockOutTime;
            private String json;
            private String videoSource;
            private String channelId;

            public String getClockDate() {
                return clockDate;
            }

            public String getClockDateSrc() {

                switch (dayOfWeek) {
                    case 1:
                        return clockDate + "(周一)";
                    case 2:
                        return clockDate + "(周二)";
                    case 3:
                        return clockDate + "(周三)";
                    case 4:
                        return clockDate + "(周四)";
                    case 5:
                        return clockDate + "(周五)";
                    case 6:
                        return clockDate + "(周六)";
                    case 7:
                        return clockDate + "(周日)";
                    default:
                        return clockDate;
                }
            }

            public void setClockDate(String clockDate) {
                this.clockDate = clockDate;
            }

            public int getDayOfWeek() {
                return dayOfWeek;
            }

            public void setDayOfWeek(int dayOfWeek) {
                this.dayOfWeek = dayOfWeek;
            }

            public String getContent() {
                return StringUtil.isEmpty(content) ? getDeviceName() : content;
            }

            public void setContent(String content) {
                this.content = content;
            }

            public String getFacilityType() {
                return facilityType;
            }

            public void setFacilityType(String facilityType) {
                this.facilityType = facilityType;
            }

            public String getFacilityName() {
                return facilityName;
            }

            public void setFacilityName(String facilityName) {
                this.facilityName = facilityName;
            }

            public String getDeviceCode() {
                return deviceCode;
            }

            public void setDeviceCode(String deviceCode) {
                this.deviceCode = deviceCode;
            }

            public String getDeviceName() {
                return StringUtil.isEmpty(deviceName) ? "" : deviceName;
            }

            public void setDeviceName(String deviceName) {
                this.deviceName = deviceName;
            }

            public String getCoordinates() {
                return coordinates;
            }

            public void setCoordinates(String coordinates) {
                this.coordinates = coordinates;
            }

            public String getCallingMode() {
                return callingMode;
            }

            public void setCallingMode(String callingMode) {
                this.callingMode = callingMode;
            }

            public Object getList() {
                return list;
            }

            public void setList(Object list) {
                this.list = list;
            }

            public String getLat() {
                return lat;
            }

            public void setLat(String lat) {
                this.lat = lat;
            }

            public String getLon() {
                return lon;
            }

            public void setLon(String lon) {
                this.lon = lon;
            }

            public String getLocation() {

                return "地址：" + location;
            }

            public void setLocation(String location) {
                this.location = location;
            }

            public String getPictureUrl() {
                return pictureUrl;
            }

            public String getPictureUrlSrc() {

                if (StringUtil.isEmpty(getPictureUrl()))
                    return "";
                else {
                    String[] src = getPictureUrl().split(",");
                    if (src.length > 0) {
                        return APIs.BASE_URL_IMG + src[0];
                    }
                    return "";
                }

            }


            public void setPictureUrl(String pictureUrl) {
                this.pictureUrl = pictureUrl;
            }

            public String getProjectCode() {
                return projectCode;
            }

            public void setProjectCode(String projectCode) {
                this.projectCode = projectCode;
            }

            public String getClockInTime() {
                return StringUtil.isEmpty(clockInTime) ? "未打卡" : clockInTime;
            }

            public void setClockInTime(String clockInTime) {
                this.clockInTime = clockInTime;
            }

            public String getClockOutTime() {
                return StringUtil.isEmpty(clockOutTime) ? "未打卡" : clockOutTime;
            }

            public void setClockOutTime(String clockOutTime) {
                this.clockOutTime = clockOutTime;
            }

            public String getJson() {
                return json;
            }

            public void setJson(String json) {
                this.json = json;
            }

            public String getId() {
                return id;
            }

            public void setId(String id) {
                this.id = id;
            }

            public String getVideoSource() {
                return videoSource;
            }

            public void setVideoSource(String videoSource) {
                this.videoSource = videoSource;
            }

            public String getChannelId() {
                return channelId;
            }

            public void setChannelId(String channelId) {
                this.channelId = channelId;
            }
        }

    }
}
